package org.example.controller;

import org.example.domain.CountSingleton;
import org.example.enums.OperEnum;
import org.example.websocket.WebSocketServer;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class CountController {

    @GetMapping("add")
    public void add() throws Exception {
        CountSingleton.setCount(OperEnum.ADD);
        WebSocketServer.broadcast(String.valueOf(CountSingleton.getCount()));
    }

    @GetMapping("sub")
    public void sub() throws Exception {
        CountSingleton.setCount(OperEnum.SUB);
        WebSocketServer.broadcast(String.valueOf(CountSingleton.getCount()));
    }

}
